<template>
	<view class="register">
		<view class="title">
			请设置登录密码
		</view>
		

		<view class="input-bg">
			<input @input="changepwd" class="uni-input" type="password" name="phone" placeholder="请输入登录密码" />
		</view>
	
		<view class="input-bg" style="margin-top:28rpx">
			<input @input="changepwd2" class="uni-input" type="password" name="phone" placeholder="请确认登录密码" />
		</view>
		
		<input type="submit" class="submit" value="注册" @click="register">
		<mpopup  ref="mpopup" :isdistance="true"></mpopup>  
	
	</view>
</template>

<script>
	var mobile,_self;
	import mpopup from '../../components/xuan-popup/xuan-popup.vue';
	export default {
		components:{
			mpopup
		},
		data() {
			return {
				title: 'Hello',
				pwd:'',
				pwd2:'',
				mobile:'',
				nickname:''
			}
		},
		onLoad: function (option) { 
		        
			this.mobile = option.mobile;
			console.log(option)
			this.nickname = option.nickname
		},
		methods: {
			changepwd(e){
				this.pwd = e.detail.value
			},
			changepwd2(e){
				this.pwd2 = e.detail.value
			},
			register(){				
				
				
				if(this.pwd != this.pwd2){
					this.$refs.mpopup.open({
						type:'err',
						content:'2次输入的密码不相同',
						timeout:2000,
					});
					return false;
				}
				_self = this;
				uni.request({
				    url: this.websiteUrl+'/userapi.php/Login/register',
					method: 'POST',
				    header: {
				    	'content-type':'application/x-www-form-urlencoded'				  
				    },
					data: {
				        mobile: this.mobile,
						nickname:_self.nickname,
						password:  _self.pwd
				    },
				    success: function (res) {
						if(res.data.code == 1){
							_self.$refs.mpopup.open({
									type:'success',
									content:res.data.msg,
									timeout:2000,
							});	
							uni.reLaunch({
							    url: '/pages/login/login'
							});
							
						}else{
							_self.$refs.mpopup.open({
									type:'info',
									content:res.data.msg,
									timeout:2000,
							});	
						}
												
												
				    }
				});	
				
				
				
				
			}
			
			

		}
	}
</script>

<style>
    .register {
		display: flex;
		flex-direction: column;
		align-items: center;
		background: #E5E5E5;
		height: 1620rpx;
	}
	.title{
		font-size:48rpx;
		line-height:48rpx;
		font-weight: bold;
		margin-top: 126rpx;
	}
	.note{
		font-size:26rpx;
		line-height: 26rpx;
		margin-top: 20rpx;
	}
	.input-bg{
		width:694rpx;
		height:112rpx;
		margin:100rpx 28rpx 28rpx 28rpx;
		background: #FFFFFF;
		border-radius: 60rpx;
	}

	.uni-input{
		width:100%;
		height:112rpx;
		line-height: 44rpx;
		font-size: 32rpx;
	    color: #AAAAAA;
		text-align: center;
	}
 .uni-input2{
	     
	    float:left;
		width:65%;
		height:112rpx;
		font-size: 32rpx;
	    color: #AAAAAA;
		text-align: center;
	}

	.get-yzm{
		float:left;
		width:25%;
		height: 112rpx;
		line-height: 112rpx;
		font-size:32rpx;
		color:#FF984C;
	}

	.submit{
		width:300rpx;
		height: 112rpx;
		margin: 60rpx 226rpx;
		background: #FF984C;
		text-align: center;
		color: white;
		line-height: 112px;
		font-size: 32rpx;
		border-radius: 60rpx;
	}
</style>
